package CAT200;
import java.sql.*;
public class newDatabaseCustomer 
{
	public static void main(String[] args)
	{
		createTableAndInsertData();
	}
	
	public static void createTableAndInsertData()
	{
		try
		{
			//Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
			DriverManager.registerDriver(new org.apache.derby.jdbc.ClientDriver());
            Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/CAT200-DB", "user", "123");
            Statement stmt = con.createStatement();
            
            stmt.executeUpdate("create table CUSTOMER" +
            		"(" +
            		"CUST_USERNAME VARCHAR(20)," +
            		"CUST_PASS VARCHAR(20)," +
            		"CUST_NAME VARCHAR(20)," +
            		"CUST_IC VARCHAR(16)," +
            		"CUST_ADDRESS VARCHAR(50)," +
            		"CUST_POSTCODE VARCHAR(5)," +
            		"CUST_STATE VARCHAR(20)," +
            		"CUST_TEL VARCHAR(12)," +
            		"CUST_EMAIL VARCHAR(50)," +
            		"BLACKLISTED CHAR(1)," +
            		"CUST_JOINDATE DATE," +
            		"Primary Key(CUST_USERNAME)" +
            		")");
            System.out.println("table inserted");
            stmt.execute("insert into CUSTOMER values ('loki', '123', 'asdloki', '890920145809', 'AG6035 Machap Umboo', '78000', 'Melaka', '0166100979', 'chenwaiken@gmail.com', null, '2010-8-31')");
            System.out.println("values inserted");
		}
		catch(Exception e){System.out.println("error :" + e); }
	}
}
